package com.cskaoyan.service;

import com.cskaoyan.bean.param.BaseParam;
import com.cskaoyan.bean.po.CommentPO;
import com.cskaoyan.bean.vo.*;
import com.cskaoyan.mapper.CommentMapper;
import com.cskaoyan.mapper.StatMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author by WANGJun
 * @date 2022/6/6 10:04
 */
@Service
public class StatServiceImpl implements StatService {

    @Autowired
    StatMapper statMapper;

    @Override
    public StatVO<StatUserVO> user() {
        List<StatUserVO> userVOList = statMapper.getStatOfUser();
        StatVO<StatUserVO> statVO = new StatVO<>();
        ArrayList<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("users");
        statVO.setColumns(columns);
        statVO.setRows(userVOList);
        return statVO;
    }

    @Override
    public StatVO<StatOrderVo> queryOrder() {
        List<StatOrderVo> orderVoList = statMapper.getStatOfOrder();
        StatVO<StatOrderVo> statVO = new StatVO<>();
        ArrayList<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("customers");
        columns.add("amount");
        columns.add("pcr");
        statVO.setColumns(columns);
        statVO.setRows(orderVoList);
        return statVO;
    }

    @Override
    public StatVO<StatGoodsVo> queryGoods() {
        List<StatGoodsVo> goodsVos = statMapper.getStatGoods();
        StatVO<StatGoodsVo> statVO = new StatVO<>();
        ArrayList<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("products");
        columns.add("amount");
        statVO.setColumns(columns);
        statVO.setRows(goodsVos);
        return statVO;
    }
}
